import cn.yunhe.dao.ProductCategoryDao;
import cn.yunhe.entity.*;
import cn.yunhe.service.*;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class ceshi {


    //测试leaveMessageDao,下的add接口，留言管理：添加
    @Test
   public void test(){
       LeaveMessageService leaveMessageService = new LeaveMessageService();
       LeaveMessage leaveMessage = new LeaveMessage();
       leaveMessage.setLeaveTitle("aaa");
       leaveMessage.setLeaveContent("aaaaaaaaaaaaa");
       User user = new User();
       user.setUserid(10);
       leaveMessage.setUser(user);
       Boolean b =  leaveMessageService.addLeaveMessage(leaveMessage);
       // System.out.println(b);
   }
   @Test
   public  void testOrderDetail(){
      /* OrderDetailService orderDetailService = new OrderDetailService();
       List<OrderDetail> orderDetailLists = orderDetailService.orderDetailList();
       System.out.println(orderDetailLists.size());
       for (OrderDetail orderDetail:orderDetailLists){
           System.out.println(orderDetail.getEodquantity());
           System.out.println(orderDetail.getEodcost());
       }*/
    }
    @Test
    public void TestSelectById(){
        SqlSession sqlSession = SqlSessionFactoryUtil.getSession();
        ProductCategoryDao productCategoryDao =  sqlSession.getMapper(ProductCategoryDao.class);
        List<ProductCategory> productCategoryList = productCategoryDao.getAllCategory();
        System.out.println(productCategoryList.size());
    }
    @Test
    public void TestSelectById2(){
        SqlSession sqlSession = SqlSessionFactoryUtil.getSession();
        ProductCategoryDao productCategoryDao =  sqlSession.getMapper(ProductCategoryDao.class);
        int id = productCategoryDao.getEpcid("图书");
        System.out.println(id);
    }
    @Test
    public void test2(){
        ProductService productService = new ProductService();
        List<Product> productList = productService.getSDtock();
        System.out.println(productList.size());
        for (Product product :productList){
            System.out.println(product.getEpname());
        }
    }
    @Test
    public  void test3(){
       LeaveMessageService leaveMessageService = new LeaveMessageService();
       List<LeaveMessage> leaveMessages = leaveMessageService.getLeaveMessage(2);
        System.out.println(leaveMessages.size());
    }

}
